import React from 'react'
import { Redirect, Route } from 'react-router-dom'
import { useSelector } from 'react-redux'

export default function PrivateRoute({ component: Component, ...rest }) {
    const isLogin = sessionStorage.getItem("isLogin")
    // const isLogin = true
    return (
        <>
            <Route {...rest} render={(props) => {
                return isLogin?<Component {...props} />:<Redirect to={{
                    pathname:"/login",
                    state:{redirect:props.location}
                }}></Redirect>
            }}></Route>
        </>
    )
}
